package com.leadingsoft.pwxk.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.leadingsoft.pwxk.converter.RegionCodeConverter;
import com.leadingsoft.pwxk.dto.RegionCodeDto;
import com.leadingsoft.pwxk.model.RegionCode;
import com.leadingsoft.pwxk.repository.RegionCodeRepository;
import com.leadingsoft.pwxk.service.RegionCodeService;

@Service
public class RegionCodeServiceImpl implements RegionCodeService {

	@Autowired
	private RegionCodeRepository regionCodeRepository;
	@Autowired
	private RegionCodeConverter regionCodeConverter;

	@Override
	public RegionCodeDto get(String dataid) {
		// RegionCode RegionCode = new RegionCode();
		return null;
	}

	@Override
	public RegionCodeDto findByRegionCode(String code) {

		RegionCode findByRegionCode = regionCodeRepository.findByRegionCode(code);
		return regionCodeConverter.toDto(findByRegionCode);
	}

	// @Cacheable(cacheNames = "codeRegion", sync = true)
	@Override
	public List<RegionCodeDto> findByparentCode(String code) {
		List<RegionCode> findByparentCode = regionCodeRepository.findByparentCode(code);
		return regionCodeConverter.toDto(findByparentCode);
	}

}
